home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume11 / sunbots / part01 next >
Encoding:
Internet Message Format  |  1990-08-20  |  54.5 KB

  1. Path: uunet!zephyr.ens.tek.com!tekred!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v11i022:  sunbots - robots/Daleks game for SunView, Part01/03
  5. Message-ID: <6126@tekred.CNA.TEK.COM>
  6. Date: 10 Aug 90 17:54:06 GMT
  7. Sender: news@tekred.CNA.TEK.COM
  8. Lines: 1801
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: Kevin Wright <kevin@altair.csustan.edu>
  12. Posting-number: Volume 11, Issue 22
  13. Archive-name: sunbots/Part01
  14.  
  15.     [I ran this on my 3/60 (OS 3.5) with no problems.  -br]
  16.  
  17. [[This is a version of robots for sunview.  It has a lot of the
  18. flavor of Daleks for the Mac.]]
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then unpack
  22. # it by saving it into a file and typing "sh file".  To overwrite existing
  23. # files, type "sh file -c".  You can also feed this as standard input via
  24. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  25. # will see the following message at the end:
  26. #        "End of archive 1 (of 3)."
  27. # Contents:  README MANIFEST level.c pics pics/human_d8.pic proc.c
  28. #   sunbots.c sunbots.h
  29. # Wrapped by billr@saab on Fri Aug 10 10:47:55 1990
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'README' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'README'\"
  33. else
  34. echo shar: Extracting \"'README'\" \(1401 characters\)
  35. sed "s/^X//" >'README' <<'END_OF_FILE'
  36. XSunbots:
  37. X
  38. XSunbots is a sunview version of Robots.  It also has additions that
  39. Xmake it resemble Daleks for the Mac.
  40. X
  41. XThe program should compile up easily enough.  Just type make and it
  42. Xshould do the rest.  You can edit the Makefile to tell it a few things
  43. Xlike where to install the game, etc.
  44. X
  45. XI don't know of any bugs in the program, of course there always could
  46. Xbe some.  There are a few things that could be done:
  47. X
  48. X    1) The filer option for saving and loading is not implemented.
  49. X       It probably wouldn't be hard at all to add this.
  50. X    2) The gems that appear on later levels should probably be
  51. X       renamed and redrawn to be Jelly Babies to fit the Dr. Who
  52. X       look of things more.
  53. X    3) My method of attempting to assure mutually exclusive access
  54. X       to the high score file during updates is a bit crude and could
  55. X       be fixed.
  56. X
  57. XPeople around our site seem to be content with the game as it is.  It is
  58. Xa mild diversion for when you are tired of doing work.
  59. X
  60. XAnyone can do anything they want with this code.  If anyone makes improvements
  61. Xor modifications to the program, it would be nice if you could send me a
  62. Xcopy of your changes so that I can take a look.
  63. X
  64. XHave Fun!
  65. X
  66. X            Kevin Wright
  67. X
  68. XE-mail : kevin@altair.csustan.edu or kevin@csustan.csustan.edu
  69. XUS-mail: California State University, Stanislaus
  70. X     Computer Science Department
  71. X     801 West Monte Vista Avenue
  72. X     Turlock, CA 95380
  73. XPhone  : (209) 667-3273
  74. END_OF_FILE
  75. if test 1401 -ne `wc -c <'README'`; then
  76.     echo shar: \"'README'\" unpacked with wrong size!
  77. fi
  78. # end of 'README'
  79. fi
  80. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  81.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  82. else
  83. echo shar: Extracting \"'MANIFEST'\" \(1212 characters\)
  84. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  85. X   File Name        Archive #    Description
  86. X-----------------------------------------------------------
  87. X MANIFEST                   1    
  88. X Makefile                   2    
  89. X README                     1    
  90. X images.c                   2    
  91. X images.h                   2    
  92. X level.c                    1    
  93. X move.c                     2    
  94. X pics                       1    
  95. X pics/debug.pic             2    
  96. X pics/filer.pic             2    
  97. X pics/gem.pic               3    
  98. X pics/human2.pic            2    
  99. X pics/human_d1.pic          2    
  100. X pics/human_d8.pic          1    
  101. X pics/icon.pic              2    
  102. X pics/live.pic              2    
  103. X pics/quit.pic              2    
  104. X pics/reset.pic             2    
  105. X pics/robot.pic             3    
  106. X pics/robot2.pic            2    
  107. X pics/scores.pic            2    
  108. X pics/sonic.pic             2    
  109. X pics/stand.pic             2    
  110. X pics/tardis.pic            2    
  111. X pics/teleport1.pic         2    
  112. X pics/teleport2.pic         2    
  113. X pics/tomb.pic              2    
  114. X pics/trash.pic             3    
  115. X pics/zap1.pic              3    
  116. X pics/zap2.pic              3    
  117. X pics/zap3.pic              3    
  118. X pics/zap4.pic              2    
  119. X proc.c                     1    
  120. X sunbots.c                  1    
  121. X sunbots.h                  1    
  122. X sunbots.man                2    
  123. END_OF_FILE
  124. if test 1212 -ne `wc -c <'MANIFEST'`; then
  125.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  126. fi
  127. # end of 'MANIFEST'
  128. fi
  129. if test -f 'level.c' -a "${1}" != "-c" ; then 
  130.   echo shar: Will not clobber existing file \"'level.c'\"
  131. else
  132. echo shar: Extracting \"'level.c'\" \(9776 characters\)
  133. sed "s/^X//" >'level.c' <<'END_OF_FILE'
  134. X/*****************************************************************
  135. X *
  136. X *    level.c    -    Level creation and manipulation routines
  137. X *
  138. X *    Created -- 1/5/90    Kevin Wright
  139. X *
  140. X *****************************************************************/
  141. X
  142. X#include "sunbots.h"    /* Robots header file */
  143. X
  144. X/*****************************************************************
  145. X *    make_level()    -    Create a new level.  Delete all
  146. X *                existing robots and create a new
  147. X *                set of them.  Reset screwdriver
  148. X *                and place all objects.
  149. X *****************************************************************/
  150. X
  151. Xmake_level()
  152. X{
  153. X    ScreenItem temp;    /* Temp pointer to robot list */
  154. X
  155. X    /* Destroy old and create new robots */
  156. X    destroy_robots();
  157. X    create_robots();
  158. X
  159. X    /* Create gems if level is right */
  160. X    if(current_level >= 10)
  161. X        create_gems();
  162. X
  163. X    /* Reset screwdriver */
  164. X    screwdriver_uses = 1;
  165. X
  166. X    /* Reset last stand */
  167. X    last_stand_set = FALSE;
  168. X
  169. X    /* Display level message */
  170. X    switch(current_level) {
  171. X        case 1:
  172. X            display_msg("Welcome to Sunbots!", 2);
  173. X            break;
  174. X        case 5:
  175. X            display_msg("Double Speed Robots", 2);
  176. X            break;
  177. X        case 10:
  178. X            display_msg("Grab Gems For Extra Points!", 2);
  179. X            break;
  180. X        default:
  181. X            break;
  182. X    }
  183. X
  184. X    /* Place human */
  185. X    human->oldrow = human->oldcol = -1;
  186. X    find_empty(human, &(human->row), (&human->col));
  187. X    place_item(human, -1, -1);
  188. X
  189. X    /* Place robots and gems */
  190. X    for(temp = robot_list; temp; temp = temp->next) {
  191. X        temp->oldrow = temp->oldcol = -1;
  192. X        find_empty(temp, &(temp->row), &(temp->col));
  193. X        place_item(temp, 0, 0);
  194. X    }
  195. X}
  196. X
  197. X
  198. X/*****************************************************************
  199. X *    remove_robots()        -    Remove robots in the
  200. X *                    specified rectangle.
  201. X *****************************************************************/
  202. X
  203. Xremove_robots(x0, y0, x1, y1, mode, score)
  204. Xint x0, y0, x1, y1, mode, score;
  205. X{
  206. X    ScreenItem temp;    /* Temp pointer to robot list */
  207. X
  208. X    temp = robot_list;
  209. X    while(temp) {
  210. X        if(temp->row >= y0 && temp->row <= y1 &&
  211. X           temp->col >= x0 && temp->col <= x1)
  212. X            if(mode == ALL_STATES ||
  213. X               (mode == LIVE_STATE && !temp->dead) ||
  214. X               (mode == DEAD_STATE && temp->dead)) {
  215. X                if(score && !temp->dead)
  216. X                    if(temp->type == SPEEDER_ROBOT)
  217. X                        update_score(10);
  218. X                    else
  219. X                        update_score(5);
  220. X                remove_item(temp);
  221. X               }
  222. X
  223. X        temp = temp->next;
  224. X    }
  225. X}
  226. X
  227. X
  228. X/*****************************************************************
  229. X *    destroy_robots()    -    Destroy all robots in the
  230. X *                    list.
  231. X *****************************************************************/
  232. X
  233. Xdestroy_robots()
  234. X{
  235. X    ScreenItem temp;    /* Temp pointer to robot list */
  236. X
  237. X    /* Traverse list and destroy each item */
  238. X    while(robot_list) {
  239. X        temp = robot_list;
  240. X        robot_list = robot_list->next;
  241. X        destroy_item(temp);
  242. X    }
  243. X
  244. X    /* Clear the playfield */
  245. X    pw_rop(playfield_pw, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
  246. X        PIX_CLR, NULL, 0, 0);
  247. X}
  248. X
  249. X
  250. X/*****************************************************************
  251. X *    remove_item()    -    Remove an item from the robot_list.
  252. X *****************************************************************/
  253. X
  254. Xremove_item(item)
  255. XScreenItem item;
  256. X{
  257. X    ScreenItem temp;    /* Temp pointer to robot list */
  258. X
  259. X    /* If item is first, then redirect main pointer */
  260. X    if(robot_list == item) {
  261. X        robot_list = robot_list->next;
  262. X        destroy_item(item);
  263. X    }
  264. X
  265. X    /* Traverse list and find item to remove */
  266. X    temp = robot_list;
  267. X    while(temp) {
  268. X        if(temp->next == item) {
  269. X            temp->next = temp->next->next;
  270. X            destroy_item(item);
  271. X        }
  272. X        temp = temp->next;
  273. X    }
  274. X}
  275. X
  276. X
  277. X/*****************************************************************
  278. X *    destroy_item()        -    Destroy a panel and free
  279. X *                    an item structure.
  280. X *****************************************************************/
  281. X
  282. Xdestroy_item(item)
  283. XScreenItem item;
  284. X{
  285. X        /* Free memory */
  286. X        free(item);
  287. X}
  288. X
  289. X
  290. X/*****************************************************************
  291. X *    create_robots()    -    Create a list of robots.  The number
  292. X *                is based on the current level.
  293. X *****************************************************************/
  294. X
  295. Xcreate_robots()
  296. X{
  297. X    int i;            /* Loop variable */
  298. X    int robot_num;        /* Number of robots on this level */
  299. X    Image image_type;    /* Type of robot image */
  300. X    ScreenItem temp;    /* Temp pointer to robots */
  301. X
  302. X    robot_num = (current_level < 12 ? 10 * current_level : 120);
  303. X
  304. X    /* Create item structures and panels for robots */
  305. X    for(i = 0; i < robot_num; i++) {
  306. X        temp = (ScreenItem) malloc(sizeof(struct screen_item));
  307. X
  308. X        if(current_level>=SPEEDER_LEVEL && RND(100)<SPEEDER_CHANCE) {
  309. X            temp->type = SPEEDER_ROBOT;
  310. X            image_type = robot2_image;
  311. X        } else {
  312. X            temp->type = NORMAL_ROBOT;
  313. X            image_type = robot_image;
  314. X        }
  315. X
  316. X        temp->image = image_type;
  317. X        temp->dead  = FALSE;
  318. X        temp->next  = robot_list;
  319. X        robot_list  = temp;
  320. X    }
  321. X}
  322. X
  323. X
  324. X/*****************************************************************
  325. X *    create_gems()
  326. X *****************************************************************/
  327. X
  328. Xcreate_gems()
  329. X{
  330. X    int i;            /* Loop variable */
  331. X    int gem_num;        /* Number of gems on this level */
  332. X    ScreenItem temp;    /* Temp pointer to gems */
  333. X
  334. X    gem_num = (current_level < 15 ? 4 * (current_level - 9) : 20);
  335. X
  336. X    /* Create item structures and panels for gems */
  337. X    for(i = 0; i < gem_num; i++) {
  338. X        temp = (ScreenItem) malloc(sizeof(struct screen_item));
  339. X        temp->type = GEM;
  340. X        temp->image = gem_image;
  341. X        temp->dead = TRUE;
  342. X        temp->next = robot_list;
  343. X        robot_list = temp;
  344. X    }
  345. X}
  346. X
  347. X
  348. X/*****************************************************************
  349. X *    find_empty()    -    Find a random empty location on the
  350. X *                screen.
  351. X *****************************************************************/
  352. X
  353. Xfind_empty(item, row, col)
  354. XScreenItem item;
  355. Xint *row, *col;
  356. X{
  357. X    ScreenItem temp;    /* Temp pointer to robot list */
  358. X    int found = TRUE;    /* Flag indicating collision found */
  359. X
  360. X    /* Find that spot */
  361. X    while(found) {
  362. X        *row = (rand() >> 3) % 40;
  363. X        *col = (rand() >> 3) % 40;
  364. X        found = (
  365. Xoccupied(item, *row, *col) != NULL);
  366. X    }
  367. X}
  368. X
  369. X
  370. X/*****************************************************************
  371. X *    occupied()    -    Check for occupation of square.
  372. X *****************************************************************/
  373. X
  374. XScreenItem occupied(item, row, col)
  375. XScreenItem item;
  376. Xint row, col;
  377. X{
  378. X    ScreenItem temp;
  379. X
  380. X    if(item != human && human->row == row && human->col == col)
  381. X        return(human);
  382. X
  383. X    temp = robot_list;
  384. X    while(temp) {
  385. X        if(item != temp && temp->row == row && temp->col == col)
  386. X            return(temp);
  387. X        temp = temp->next;
  388. X    }
  389. X
  390. X    return(NULL);
  391. X}
  392. X
  393. X/*****************************************************************
  394. X *    place_item()    -    Set the row/col values for an item
  395. X *                and redisplay.
  396. X *****************************************************************/
  397. X
  398. Xplace_item(item, xoffset, yoffset)
  399. XScreenItem item;
  400. Xint xoffset, yoffset;
  401. X{
  402. X    int row, col, oldrow, oldcol;
  403. X
  404. X    /* Calculate pixel offsets */
  405. X    oldrow = ROW_HEIGHT * (item->oldrow + yoffset);
  406. X    oldcol = COL_WIDTH * (item->oldcol + xoffset);
  407. X    row = ROW_HEIGHT * (item->row + yoffset);
  408. X    col = COL_WIDTH  * (item->col + xoffset);
  409. X
  410. X    /* Clear old picture and place new picture */
  411. X    pw_rop(playfield_pw, oldcol, oldrow, item->image->width,
  412. X        item->image->height, PIX_CLR, NULL, 0, 0);
  413. X    pw_rop(playfield_pw, col, row, item->image->width,
  414. X        item->image->height, PIX_SRC, item->image->picture, 0, 0);
  415. X}
  416. X
  417. X
  418. X/*****************************************************************
  419. X *    set_image()    -    Change the image of the specified
  420. X *                item.
  421. X *****************************************************************/
  422. X
  423. Xset_image(item, newimage, xoffset, yoffset)
  424. XScreenItem item;
  425. XImage newimage;
  426. Xint xoffset, yoffset;
  427. X{
  428. X    int row, col;
  429. X
  430. X    /* Calculate pixel offsets */
  431. X    row = ROW_HEIGHT * (item->row + yoffset);
  432. X    col = COL_WIDTH  * (item->col + xoffset);
  433. X
  434. X    /* Clear old picture and place new picture */
  435. X    pw_rop(playfield_pw, col, row, item->image->width,
  436. X        item->image->height, PIX_CLR, NULL, 0, 0);
  437. X    pw_rop(playfield_pw, col, row, item->image->width,
  438. X        item->image->height, PIX_SRC, newimage->picture, 0, 0);
  439. X
  440. X    item->image = newimage;
  441. X}
  442. X
  443. X
  444. X/*****************************************************************
  445. X *    refresh_image()    -    Redraw the picture for an item.
  446. X *****************************************************************/
  447. X
  448. Xrefresh_image(item, xoffset, yoffset)
  449. XScreenItem item;
  450. Xint xoffset, yoffset;
  451. X{
  452. X    int row, col;
  453. X
  454. X    /* Calculate pixel offsets */
  455. X    row = ROW_HEIGHT * (item->row + yoffset);
  456. X    col = COL_WIDTH  * (item->col + xoffset);
  457. X
  458. X    pw_rop(playfield_pw, col, row, item->image->width,
  459. X        item->image->height, PIX_SRC, item->image->picture, 0, 0);
  460. X}
  461. X
  462. X
  463. X/*****************************************************************
  464. X *    update_score()    -    Update the score by the given
  465. X *                amount and redisplay it.
  466. X *****************************************************************/
  467. X
  468. Xupdate_score(amount)
  469. Xint amount;
  470. X{
  471. X    char temp_string[80];        /* Temporary storage string */
  472. X
  473. X    /* Add amount and create new string */
  474. X    current_score += amount;
  475. X    sprintf(temp_string, "Level %6d     Score %6d",
  476. X        current_level, current_score);
  477. X
  478. X    /* Display new string */
  479. X    panel_set(score, PANEL_LABEL_STRING, temp_string, 0);
  480. X}
  481. X
  482. X
  483. X/*****************************************************************
  484. X *    update_level()    -    Update the level by the given
  485. X *                amount and redisplay it.
  486. X *****************************************************************/
  487. X
  488. Xupdate_level(amount)
  489. Xint amount;
  490. X{
  491. X    char temp_string[80];        /* Temporary storage string */
  492. X
  493. X    /* Add amount and create new string */
  494. X    current_level += amount;
  495. X    sprintf(temp_string, "Level %6d     Score %6d",
  496. X        current_level, current_score);
  497. X
  498. X    /* Display new string */
  499. X    panel_set(score, PANEL_LABEL_STRING, temp_string, 0);
  500. X}
  501. X
  502. X
  503. X/*****************************************************************
  504. X *    do_death()    -    Display a tomb stone where the
  505. X *                player used to be.
  506. X *****************************************************************/
  507. X
  508. Xdo_death()
  509. X{
  510. X    /* Change human picture to tombstone */
  511. X    set_image(human, tomb_image, -1, -1);
  512. X
  513. X    make_hs();
  514. X    if(!window_get(hs_popup_frame, WIN_SHOW))
  515. X        do_pop_proc();
  516. X}
  517. X
  518. X
  519. END_OF_FILE
  520. if test 9776 -ne `wc -c <'level.c'`; then
  521.     echo shar: \"'level.c'\" unpacked with wrong size!
  522. fi
  523. # end of 'level.c'
  524. fi
  525. if test ! -d 'pics' ; then
  526.     echo shar: Creating directory \"'pics'\"
  527.     mkdir 'pics'
  528. fi
  529. if test -f 'pics/human_d8.pic' -a "${1}" != "-c" ; then 
  530.   echo shar: Will not clobber existing file \"'pics/human_d8.pic'\"
  531. else
  532. echo shar: Extracting \"'pics/human_d8.pic'\" \(8429 characters\)
  533. sed "s/^X//" >'pics/human_d8.pic' <<'END_OF_FILE'
  534. X/* Format_version=1, Width=48, Height=48, Depth=8, Valid_bits_per_item=16
  535. X */
  536. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  537. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  538. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  539. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  540. X    0x0000,0x0000,0x0000,0x0202,0x0202,0x0000,0x0000,0x0000,
  541. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  542. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  543. X    0x0000,0x0000,0x0002,0x0202,0x0202,0x0200,0x0000,0x0000,
  544. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  545. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  546. X    0x0000,0x0000,0x0002,0x0202,0x0202,0x0200,0x0000,0x0000,
  547. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  548. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  549. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  550. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  551. X    0x0000,0x0000,0x0002,0x0202,0x0202,0x0000,0x0000,0x0000,
  552. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  553. X    0x0000,0x0000,0x0000,0x0202,0x0202,0x0200,0x0000,0x0000,
  554. X    0x0000,0x0000,0x0002,0x0202,0x0202,0x0000,0x0000,0x0000,
  555. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  556. X    0x0000,0x0000,0x0000,0x0202,0x0202,0x0200,0x0000,0x0000,
  557. X    0x0000,0x0000,0x0002,0x0202,0x0200,0x0000,0x0000,0x0000,
  558. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  559. X    0x0000,0x0000,0x0000,0x0002,0x0202,0x0200,0x0000,0x0000,
  560. X    0x0000,0x0000,0x0002,0x0202,0x0202,0x0000,0x0000,0x0000,
  561. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  562. X    0x0000,0x0000,0x0000,0x0202,0x0202,0x0200,0x0000,0x0000,
  563. X    0x0000,0x0000,0x0002,0x0200,0x0202,0x0200,0x0000,0x0000,
  564. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  565. X    0x0000,0x0000,0x0002,0x0202,0x0002,0x0200,0x0000,0x0000,
  566. X    0x0000,0x0000,0x0000,0x0000,0x0002,0x0202,0x0000,0x0000,
  567. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  568. X    0x0000,0x0000,0x0202,0x0200,0x0000,0x0000,0x0000,0x0000,
  569. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0202,0x0200,0x0000,
  570. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  571. X    0x0000,0x0002,0x0202,0x0000,0x0000,0x0000,0x0000,0x0000,
  572. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0002,0x0202,0x0000,
  573. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  574. X    0x0000,0x0202,0x0200,0x0000,0x0000,0x0000,0x0000,0x0000,
  575. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0202,0x0200,
  576. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  577. X    0x0002,0x0202,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  578. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0002,0x0000,
  579. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  580. X    0x0000,0x0200,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  581. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  582. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  583. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  584. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  585. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  586. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  587. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  588. X    0x0000,0x0000,0x0000,0x0202,0x0202,0x0000,0x0000,0x0000,
  589. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  590. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  591. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  592. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  593. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  594. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  595. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  596. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  597. X    0x0000,0x0000,0x0002,0x0202,0x0202,0x0200,0x0000,0x0000,
  598. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  599. X    0x0000,0x0202,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  600. X    0x0000,0x0000,0x0202,0x0202,0x0202,0x0202,0x0000,0x0000,
  601. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0202,0x0000,
  602. X    0x0002,0x0202,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  603. X    0x0000,0x0002,0x0200,0x0202,0x0202,0x0002,0x0200,0x0000,
  604. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0202,0x0200,
  605. X    0x0202,0x0202,0x0202,0x0202,0x0202,0x0202,0x0000,0x0000,
  606. X    0x0000,0x0002,0x0000,0x0202,0x0202,0x0000,0x0200,0x0000,
  607. X    0x0000,0x0000,0x0202,0x0202,0x0202,0x0202,0x0202,0x0202,
  608. X    0x0202,0x0202,0x0202,0x0202,0x0202,0x0202,0x0000,0x0000,
  609. X    0x0000,0x0000,0x0000,0x0202,0x0202,0x0000,0x0000,0x0000,
  610. X    0x0000,0x0000,0x0202,0x0202,0x0202,0x0202,0x0202,0x0202,
  611. X    0x0002,0x0202,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  612. X    0x0000,0x0000,0x0000,0x0202,0x0202,0x0000,0x0000,0x0000,
  613. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0202,0x0200,
  614. X    0x0000,0x0202,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  615. X    0x0000,0x0000,0x0000,0x0202,0x0202,0x0000,0x0000,0x0000,
  616. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0202,0x0000,
  617. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  618. X    0x0000,0x0000,0x0000,0x0200,0x0002,0x0000,0x0000,0x0000,
  619. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  620. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  621. X    0x0000,0x0000,0x0000,0x0200,0x0002,0x0000,0x0000,0x0000,
  622. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  623. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  624. X    0x0000,0x0000,0x0000,0x0200,0x0002,0x0000,0x0000,0x0000,
  625. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  626. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  627. X    0x0000,0x0000,0x0202,0x0200,0x0002,0x0202,0x0000,0x0000,
  628. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  629. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  630. X    0x0000,0x0000,0x0202,0x0200,0x0002,0x0202,0x0000,0x0000,
  631. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  632. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  633. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  634. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  635. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0002,0x0000,
  636. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  637. X    0x0000,0x0200,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  638. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0202,0x0200,
  639. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  640. X    0x0002,0x0202,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  641. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0002,0x0202,0x0000,
  642. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  643. X    0x0000,0x0202,0x0200,0x0000,0x0000,0x0000,0x0000,0x0000,
  644. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0202,0x0200,0x0000,
  645. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  646. X    0x0000,0x0002,0x0202,0x0000,0x0000,0x0000,0x0000,0x0000,
  647. X    0x0000,0x0000,0x0000,0x0000,0x0002,0x0202,0x0000,0x0000,
  648. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  649. X    0x0000,0x0000,0x0202,0x0200,0x0000,0x0000,0x0000,0x0000,
  650. X    0x0000,0x0000,0x0002,0x0200,0x0202,0x0200,0x0000,0x0000,
  651. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  652. X    0x0000,0x0000,0x0002,0x0202,0x0002,0x0200,0x0000,0x0000,
  653. X    0x0000,0x0000,0x0002,0x0202,0x0202,0x0000,0x0000,0x0000,
  654. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  655. X    0x0000,0x0000,0x0000,0x0202,0x0202,0x0200,0x0000,0x0000,
  656. X    0x0000,0x0000,0x0002,0x0202,0x0200,0x0000,0x0000,0x0000,
  657. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  658. X    0x0000,0x0000,0x0000,0x0002,0x0202,0x0200,0x0000,0x0000,
  659. X    0x0000,0x0000,0x0002,0x0202,0x0202,0x0000,0x0000,0x0000,
  660. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  661. X    0x0000,0x0000,0x0000,0x0202,0x0202,0x0200,0x0000,0x0000,
  662. X    0x0000,0x0000,0x0002,0x0202,0x0202,0x0000,0x0000,0x0000,
  663. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  664. X    0x0000,0x0000,0x0000,0x0202,0x0202,0x0200,0x0000,0x0000,
  665. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  666. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  667. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  668. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  669. X    0x0000,0x0000,0x0002,0x0202,0x0202,0x0200,0x0000,0x0000,
  670. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  671. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  672. X    0x0000,0x0000,0x0002,0x0202,0x0202,0x0200,0x0000,0x0000,
  673. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  674. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  675. X    0x0000,0x0000,0x0000,0x0202,0x0202,0x0000,0x0000,0x0000,
  676. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  677. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  678. X    0x0000,0x0000,0x0000,0x0002,0x0200,0x0000,0x0000,0x0000,
  679. X    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
  680. END_OF_FILE
  681. if test 8429 -ne `wc -c <'pics/human_d8.pic'`; then
  682.     echo shar: \"'pics/human_d8.pic'\" unpacked with wrong size!
  683. fi
  684. # end of 'pics/human_d8.pic'
  685. fi
  686. if test -f 'proc.c' -a "${1}" != "-c" ; then 
  687.   echo shar: Will not clobber existing file \"'proc.c'\"
  688. else
  689. echo shar: Extracting \"'proc.c'\" \(7724 characters\)
  690. sed "s/^X//" >'proc.c' <<'END_OF_FILE'
  691. X/*****************************************************************
  692. X *
  693. X *    proc.c    -    Icon activated processes.
  694. X *
  695. X *    Created -- 1/5/90    Kevin Wright
  696. X *
  697. X *****************************************************************/
  698. X
  699. X#include "sunbots.h"    /* Robots header file */
  700. X
  701. X/*****************************************************************
  702. X *    new_proc()    -    This procedure is called at the
  703. X *                start and whenever reset is pressed.
  704. X *                If the human object does not exist,
  705. X *                then it is created.  The score and
  706. X *                level are reset.  The first level
  707. X *                is created.
  708. X *****************************************************************/
  709. X
  710. Xnew_proc()
  711. X{
  712. X    /* Create the human */
  713. X    if(!human) {
  714. X        human = (ScreenItem) malloc(sizeof(struct screen_item));
  715. X        human->image = human_image;
  716. X        human->next = NULL;
  717. X    }
  718. X
  719. X    /* Reset human to alive and looking like a human */
  720. X    human->type = HUMAN;
  721. X    human->dead = FALSE;
  722. X    human->image = human_image;
  723. X    human->oldrow = human->oldcol = -1;
  724. X
  725. X    /* Reset score, level, and lives. Make first level */
  726. X    update_score(-current_score);
  727. X    update_level(1 - current_level);
  728. X    lives_remaining = 2;
  729. X    make_level();
  730. X}
  731. X
  732. X
  733. X/*****************************************************************
  734. X *    filer_proc()    -    Not Implemented Yet
  735. X *****************************************************************/
  736. X
  737. Xfiler_proc()
  738. X{
  739. X}
  740. X
  741. X
  742. X/*****************************************************************
  743. X *    teleport_proc()    -    Teleport the human to a random
  744. X *                place on the screen.  An empty
  745. X *                location is found and the human is
  746. X *                moved there.  Robots move after a
  747. X *                teleportation occurs.
  748. X *****************************************************************/
  749. X
  750. Xteleport_proc()
  751. X{
  752. X    int i, j;        /* Loop variables */
  753. X
  754. X    /* If the human is dead, forget it */
  755. X    if(human->dead)
  756. X        return;
  757. X
  758. X    /* Make some fancy display */
  759. X    for(i = 0; i < 10; i++) {
  760. X        set_image(human, teleport_image[1], -1, -1);
  761. X        for(j = 0; j < TARDIS_BLINK_RATE; j++)
  762. X            ;
  763. X        set_image(human, teleport_image[0], -1, -1);
  764. X        for(j = 0; j < TARDIS_BLINK_RATE; j++)
  765. X            ;
  766. X    }
  767. X
  768. X    /* Find an empty place and put the human there */
  769. X    human->oldrow = human->row;
  770. X    human->oldcol = human->col;
  771. X    find_empty(human, &(human->row), (&human->col));
  772. X    place_item(human, -1, -1);
  773. X
  774. X    /* Make some more fancy display */
  775. X    for(i = 0; i < 10; i++) {
  776. X        set_image(human, teleport_image[1], -1, -1);
  777. X        for(j = 0; j < TARDIS_BLINK_RATE; j++)
  778. X            ;
  779. X        set_image(human, teleport_image[0], -1, -1);
  780. X        for(j = 0; j < TARDIS_BLINK_RATE; j++)
  781. X            ;
  782. X    }
  783. X
  784. X    /* Put the human back to normal and move the robots */
  785. X    set_image(human, human_image, -1, -1);
  786. X    move_robots(ALL_ROBOTS);
  787. X}
  788. X
  789. X
  790. X/*****************************************************************
  791. X *    sonic_proc()    -    Activate sonic screwdriver.
  792. X *                Draw sonic blast and then remove
  793. X *                all robots in blast range.
  794. X *                Remove one use from screwdriver.
  795. X *****************************************************************/
  796. X
  797. Xsonic_proc()
  798. X{
  799. X    int i, j, k;        /* Loop variables */
  800. X
  801. X    /* If human is dead or screwdriver is empty, then forget it */
  802. X    if(!screwdriver_uses || human->dead)
  803. X        return;
  804. X
  805. X    /* Decrement uses and draw zap */
  806. X    screwdriver_uses--;
  807. X    set_image(human, zap_image[0], -1, -1);
  808. X    for(i = 0; i < 10; i++) {
  809. X        for(j = 1; j < 4; j++) {
  810. X            set_image(human, zap_image[j], -1, -1);
  811. X            for(k = 1; k < SONIC_CYCLE_RATE; k++)
  812. X                ;
  813. X        }
  814. X        for(j = 2; j >= 0; j--) {
  815. X            set_image(human, zap_image[j], -1, -1);
  816. X            for(k = 1; k < SONIC_CYCLE_RATE; k++)
  817. X                ;
  818. X        }
  819. X    }
  820. X    set_image(human, human_image, -1, -1);
  821. X
  822. X    /* Remove robots and let remaining robots move */
  823. X    remove_robots(human->col-1, human->row-1,
  824. X            human->col+1, human->row+1, LIVE_STATE, TRUE);
  825. X    move_robots(ALL_ROBOTS);
  826. X}
  827. X
  828. X
  829. X/*****************************************************************
  830. X *    stand_proc()    -    Let the player make a last stand.
  831. X *                Move robots until human is dead or
  832. X *                all robots are dead.
  833. X *****************************************************************/
  834. X
  835. Xstand_proc()
  836. X{
  837. X    /* If human is dead, then forget it */
  838. X    if(human->dead)
  839. X        return;
  840. X
  841. X    /* Set last stand flag */
  842. X    last_stand_set = TRUE;
  843. X
  844. X    /* Move the robots */
  845. X    while(move_robots(ALL_ROBOTS))
  846. X        ;
  847. X}
  848. X
  849. X
  850. X/*****************************************************************
  851. X *    quit_proc()    -    Put up an alert for confirmation
  852. X *                of quit.  If OK, then destroy
  853. X *                the frame, else return to game.
  854. X *****************************************************************/
  855. X
  856. Xquit_proc()
  857. X{
  858. X#ifdef SUNOS3_5
  859. X    window_destroy(frame);
  860. X#else
  861. X    int    result;        /* Result from alert */
  862. X    Event    event;        /* Event from alert */
  863. X
  864. X    /* Get result from an alert */
  865. X    result = alert_prompt(frame, &event,
  866. X        ALERT_MESSAGE_STRINGS,    "Are you sure you want to Quit?", 0,
  867. X        ALERT_BUTTON_YES,    "Confirm",
  868. X        ALERT_BUTTON_NO,    "Cancel",
  869. X        0);
  870. X
  871. X    /* Process result */
  872. X    switch(result) {
  873. X        case ALERT_YES:
  874. X            window_destroy(frame);
  875. X            break;
  876. X        default:
  877. X            break;
  878. X    }
  879. X#endif
  880. X}
  881. X
  882. X
  883. X/*****************************************************************
  884. X *    move_proc()    -    Get mouse coordinates from playfield
  885. X *                and make player move toward the click.
  886. X *****************************************************************/
  887. X
  888. Xmove_proc(canvas, event)
  889. XCanvas canvas;
  890. XEvent *event;
  891. X{
  892. X    int level;        /* Level activated on */
  893. X    int action;        /* The event action */
  894. X    int row, col;        /* Row and column of mouse click */
  895. X
  896. X    /* If not right or left mouse click or human is dead, forget it */
  897. X#ifdef SUNOS3_5
  898. X    action = event_id(event);
  899. X#else
  900. X    action = event_action(event);
  901. X#endif
  902. X    if((action != MS_RIGHT && action != MS_LEFT &&
  903. X        action != MS_MIDDLE && action != KEY_TOP(1) &&
  904. X        action != KEY_TOP(2)) || human->dead)
  905. X        return;
  906. X
  907. X    /* Convert coordinates to row/col */
  908. X    row = event_y(event) / ROW_HEIGHT;
  909. X    col = event_x(event) / COL_WIDTH;
  910. X    level = current_level;
  911. X
  912. X    if(action == KEY_TOP(1)) {
  913. X        dump_pic();
  914. X        return;
  915. X    }
  916. X    if(action == KEY_TOP(2)) {
  917. X        dump_hs();
  918. X        return;
  919. X    }
  920. X
  921. X    if(action == MS_LEFT)
  922. X        move_one(row, col);
  923. X    else
  924. X        while(TRUE) {
  925. X            /* If human dead or robots dead, stop */
  926. X            if(level != current_level || human->dead)
  927. X                break;
  928. X
  929. X            /* If we are doing safe move, then think */
  930. X            if(action == MS_MIDDLE && unsafe(row, col))
  931. X                teleport_proc();
  932. X
  933. X            /* Move once */
  934. X            move_one(row, col);
  935. X
  936. X            /* If we arrive, then stop */
  937. X            if(row == human->row && col == human->col)
  938. X                break;
  939. X        }
  940. X}
  941. X
  942. X
  943. X/*****************************************************************
  944. X *    do_pop_proc()    -    Add or remove the popup high
  945. X *                score window.
  946. X *****************************************************************/
  947. X
  948. Xdo_pop_proc()
  949. X{
  950. X    /* If not shown, refresh and display, else remove it */
  951. X    if(!window_get(hs_popup_frame, WIN_SHOW)) {
  952. X        get_hs();
  953. X        update_hs();
  954. X        window_set(hs_popup_frame, WIN_SHOW, TRUE, 0);
  955. X    } else
  956. X        window_set(hs_popup_frame, WIN_SHOW, FALSE, 0);
  957. X}
  958. X
  959. X
  960. X/*
  961. X *
  962. X */
  963. X
  964. Xsetup_proc()
  965. X{
  966. X    struct itimerval timer;        /* Timer for removing message */
  967. X
  968. X    timer.it_interval.tv_usec = 0;
  969. X    timer.it_interval.tv_sec = 1;
  970. X    timer.it_value.tv_usec = 0;
  971. X    timer.it_value.tv_sec = 1;
  972. X
  973. X    notify_set_itimer_func(msg_popup_frame, startup_proc,
  974. X            ITIMER_REAL, &timer, NULL);
  975. X}
  976. X
  977. X
  978. X/*
  979. X *
  980. X */
  981. X
  982. Xstartup_proc()
  983. X{
  984. X    new_proc();
  985. X}
  986. X
  987. X
  988. X/*****************************************************************
  989. X *    debug_proc()    -    For debugging.  Teleport one
  990. X *                level.
  991. X *****************************************************************/
  992. X
  993. Xdebug_proc()
  994. X{
  995. X    /* Go up one level */
  996. X    update_level(1);
  997. X    make_level();
  998. X}
  999. X
  1000. X
  1001. X/*****************************************************************
  1002. X *    live_proc()    -    For debugging.  Bring human back
  1003. X *                to life.
  1004. X *****************************************************************/
  1005. X
  1006. Xlive_proc()
  1007. X{
  1008. X    ScreenItem temp;
  1009. X
  1010. X    /* Bring human back to life */
  1011. X    human->dead = FALSE;
  1012. X    set_image(human, human_image, -1, -1);
  1013. X
  1014. X    /* Refresh the robots */
  1015. X    temp = robot_list;
  1016. X    while(temp) {
  1017. X        refresh_image(temp, 0, 0);
  1018. X        temp = temp->next;
  1019. X    }
  1020. X
  1021. X}
  1022. X
  1023. X
  1024. END_OF_FILE
  1025. if test 7724 -ne `wc -c <'proc.c'`; then
  1026.     echo shar: \"'proc.c'\" unpacked with wrong size!
  1027. fi
  1028. # end of 'proc.c'
  1029. fi
  1030. if test -f 'sunbots.c' -a "${1}" != "-c" ; then 
  1031.   echo shar: Will not clobber existing file \"'sunbots.c'\"
  1032. else
  1033. echo shar: Extracting \"'sunbots.c'\" \(16439 characters\)
  1034. sed "s/^X//" >'sunbots.c' <<'END_OF_FILE'
  1035. X/*****************************************************************
  1036. X *
  1037. X *    sunbots.c    -    Robots for SunView
  1038. X *
  1039. X *    Created -- 1/5/90    Kevin Wright
  1040. X *
  1041. X *****************************************************************/
  1042. X
  1043. X#include "sunbots.h"    /* Robots header file */
  1044. X
  1045. X/*
  1046. X *    Global Variables
  1047. X */
  1048. X
  1049. XFrame        frame;            /* Base frame for window */
  1050. XFrame        hs_popup_frame;        /* High score popup sub-frame */
  1051. XFrame        msg_popup_frame;    /* Message popup sub-frame */
  1052. XCanvas        playfield;        /* Main battlefield for robots */
  1053. XPixwin        *playfield_pw;        /* Pixwin for the battlefield */
  1054. XPixwin        *window_pw;        /* Pixwin for the window */
  1055. XPanel        msg_window;        /* Panel for displaying score */
  1056. XPanel        cmd_window;        /* Panel that contains buttons */
  1057. XPanel        mov_window;        /* Panel containing movement gadgets */
  1058. XPanel        hs_popup_panel;        /* High score popup sub-window */
  1059. XPanel        msg_popup_panel;    /* Message popup sub-window */
  1060. XPanel_item    score;            /* Item to display score and level */
  1061. XPanel_item    msg_popup_label;    /* Label for popup panel */
  1062. XPanel_item    hs[10] = {0,0,0,0,0,0,0,0,0,0};    /* Top ten score panels */
  1063. XScreenItem    human = NULL;        /* Structure containing human */
  1064. XScreenItem    robot_list = NULL;    /* Linked list of robots */
  1065. X
  1066. XHiScoreList    hs_list;        /* High score chart */
  1067. X
  1068. Xint        current_level;        /* Current level number */
  1069. Xint        current_score;        /* Current score */
  1070. Xint        screwdriver_uses;    /* How many sonic blasts */
  1071. Xint        last_stand_set;        /* Are we doing a last stand */
  1072. Xint        lives_remaining;    /* Number of lives remaining */
  1073. X
  1074. X
  1075. X/*****************************************************************
  1076. X *    main()    -    The base frame is created with title
  1077. X *            "Robots".  The images are initialized.
  1078. X *            The message, playfield, and command
  1079. X *            windows are set up and the game is started.
  1080. X *****************************************************************/
  1081. X
  1082. Xvoid main(argc, argv)
  1083. Xint argc;
  1084. Xchar **argv;
  1085. X{
  1086. X    /* Seed random numbers */
  1087. X    SEED(time(NULL));
  1088. X
  1089. X    /* Build base frame */
  1090. X    frame = window_create(NULL, FRAME,
  1091. X            FRAME_ARGS,        argc,    argv,
  1092. X            FRAME_LABEL,        "Sunbots v2.0",
  1093. X#ifndef SUNOS3_5
  1094. X            FRAME_NO_CONFIRM,    TRUE,
  1095. X#endif
  1096. X            FRAME_ICON,        icon_image,
  1097. X            0);
  1098. X
  1099. X    /* Init some panels */
  1100. X    init_msg_window();
  1101. X    init_playfield();
  1102. X
  1103. X    /* Create the pixrect images */
  1104. X    make_pics();
  1105. X
  1106. X    /* Init remaining panels */
  1107. X    init_cmd_window();
  1108. X    init_hs_popup();
  1109. X    init_msg_popup();
  1110. X
  1111. X    /* Setup to start a new game */
  1112. X    setup_proc();
  1113. X
  1114. X    /* Fit the frame and do window loop */
  1115. X    window_fit(frame);
  1116. X    window_main_loop(frame);
  1117. X
  1118. X    exit(0);
  1119. X}
  1120. X
  1121. X
  1122. X/*****************************************************************
  1123. X *    init_msg_window()    -    The message window is
  1124. X *                    created.  It contains the
  1125. X *                    level and score.
  1126. X *****************************************************************/
  1127. X
  1128. Xinit_msg_window()
  1129. X{
  1130. X    /* Create message window */
  1131. X    msg_window = window_create(frame, PANEL,
  1132. X            WIN_ROWS,    1,
  1133. X            0);
  1134. X
  1135. X    /* Create item to display level and score */
  1136. X    score = panel_create_item(msg_window,    PANEL_MESSAGE,
  1137. X            PANEL_LABEL_STRING,    "Level      0     Score      0",
  1138. X            0);
  1139. X}
  1140. X
  1141. X
  1142. X/*****************************************************************
  1143. X *    init_playfield()    -    The playfield is created.
  1144. X *                    There are no margins and
  1145. X *                    no row/col gaps.  The
  1146. X *                    only events that are noticed
  1147. X *                    by this window are those
  1148. X *                    from the left mouse button.
  1149. X *****************************************************************/
  1150. X
  1151. Xinit_playfield()
  1152. X{
  1153. X    int i;
  1154. X    unsigned char red[4], green[4], blue[4];
  1155. X
  1156. X    /* Create playfield window */
  1157. X    playfield = window_create(frame, CANVAS,
  1158. X            WIN_ROW_HEIGHT,        ROW_HEIGHT,
  1159. X            WIN_COLUMN_WIDTH,    COL_WIDTH,
  1160. X            WIN_ROW_GAP,        0,
  1161. X            WIN_COLUMN_GAP,        0,
  1162. X            WIN_LEFT_MARGIN,    0,
  1163. X            WIN_RIGHT_MARGIN,    0,
  1164. X            WIN_TOP_MARGIN,        0,
  1165. X            WIN_BOTTOM_MARGIN,    0,
  1166. X            WIN_ROWS,        SCRN_ROWS,
  1167. X            WIN_COLUMNS,        SCRN_COLS,
  1168. X            WIN_BELOW,        msg_window,
  1169. X            WIN_CONSUME_KBD_EVENTS, WIN_NO_EVENTS,
  1170. X                        KEY_TOP(1),
  1171. X                        KEY_TOP(2),
  1172. X                        0,
  1173. X            WIN_CONSUME_PICK_EVENTS,WIN_NO_EVENTS,
  1174. X                        MS_LEFT, MS_RIGHT, MS_MIDDLE,
  1175. X                        0,
  1176. X            WIN_EVENT_PROC,        move_proc,
  1177. X            CANVAS_RETAINED,    FALSE,
  1178. X            0);
  1179. X
  1180. X    /* Get pixwin of playfield and window */
  1181. X    window_pw = (Pixwin *) window_get(playfield, WIN_PIXWIN);
  1182. X    playfield_pw = canvas_pixwin(playfield);
  1183. X    
  1184. X    /* Set color values */
  1185. X    if(window_pw->pw_pixrect->pr_depth == 1)
  1186. X        for(i = 0; i < 4; i++) {
  1187. X            red[i]   = (i == 0 ? 255 : 0);
  1188. X            green[i] = (i == 0 ? 255 : 0);
  1189. X            blue[i]  = (i == 0 ? 255 : 0);
  1190. X        }
  1191. X    else
  1192. X        for(i = 0; i < 4; i++) {
  1193. X            red[i]   = (i == 3 || i == 0 ? 255 : 0);
  1194. X            green[i] = (i == 2 || i == 0 ? 255 : 0);
  1195. X            blue[i]  = (i == 1 || i == 0 ? 255 : 0);
  1196. X        }
  1197. X
  1198. X    /* Set color map for WIN_PIXWIN */
  1199. X    pw_setcmsname(window_pw, "playfield_cm");
  1200. X    pw_putcolormap(window_pw, 0, 4, red, green, blue);
  1201. X
  1202. X    /* Set color map for CANVAS_PIXWIN */
  1203. X    pw_setcmsname(playfield_pw, "playfield_cm");
  1204. X    pw_putcolormap(playfield_pw, 0, 4, red, green, blue);
  1205. X
  1206. X    /* Set canvas to retain */
  1207. X    window_set(playfield, CANVAS_RETAINED, TRUE, 0);
  1208. X}
  1209. X
  1210. X
  1211. X/*****************************************************************
  1212. X *    init_cmd_window()    -    The command window is
  1213. X *                    created and buttons are
  1214. X *                    created for each command.
  1215. X *****************************************************************/
  1216. X
  1217. Xinit_cmd_window()
  1218. X{
  1219. X    /* Create command window */
  1220. X    cmd_window = window_create(frame, PANEL,
  1221. X            WIN_BELOW,        msg_window,
  1222. X            WIN_RIGHT_OF,        playfield,
  1223. X            WIN_WIDTH,        75,
  1224. X            WIN_LEFT_MARGIN,    5,
  1225. X            WIN_RIGHT_MARGIN,    5,
  1226. X            0);
  1227. X
  1228. X    /* Create high scores gadget */
  1229. X    panel_create_item(cmd_window, PANEL_BUTTON,
  1230. X        PANEL_LABEL_IMAGE, scores_image->picture,
  1231. X        PANEL_NOTIFY_PROC, do_pop_proc,
  1232. X        0);
  1233. X
  1234. X    /* Create reset gadget */
  1235. X    panel_create_item(cmd_window, PANEL_BUTTON,
  1236. X        PANEL_LABEL_IMAGE, reset_image->picture,
  1237. X        PANEL_NOTIFY_PROC, new_proc,
  1238. X        0);
  1239. X
  1240. X    /* Create quit gadget */
  1241. X    panel_create_item(cmd_window, PANEL_BUTTON,
  1242. X        PANEL_LABEL_IMAGE, quit_image->picture,
  1243. X        PANEL_NOTIFY_PROC, quit_proc,
  1244. X        0);
  1245. X
  1246. X    /* Create last stand gadget */
  1247. X    panel_create_item(cmd_window, PANEL_BUTTON,
  1248. X        PANEL_LABEL_IMAGE, stand_image->picture,
  1249. X        PANEL_NOTIFY_PROC, stand_proc,
  1250. X        0);
  1251. X
  1252. X    /* Create sonic screwdriver gadget */
  1253. X    panel_create_item(cmd_window, PANEL_BUTTON,
  1254. X        PANEL_LABEL_IMAGE, sonic_image->picture,
  1255. X        PANEL_NOTIFY_PROC, sonic_proc,
  1256. X        0);
  1257. X
  1258. X    /* Create teleportation gadget */
  1259. X    panel_create_item(cmd_window, PANEL_BUTTON,
  1260. X        PANEL_LABEL_IMAGE, tardis_image->picture,
  1261. X        PANEL_NOTIFY_PROC, teleport_proc,
  1262. X        0);
  1263. X
  1264. X    /* Create filer gadget */
  1265. X    panel_create_item(cmd_window, PANEL_BUTTON,
  1266. X        PANEL_LABEL_IMAGE, filer_image->picture,
  1267. X        PANEL_NOTIFY_PROC, filer_proc,
  1268. X        0);
  1269. X
  1270. X    /* If UID = debugger, then put up debug icon */
  1271. X    if(getuid() == DEBUG_UID) {
  1272. X        panel_create_item(cmd_window, PANEL_BUTTON,
  1273. X            PANEL_LABEL_IMAGE, debug_image->picture,
  1274. X            PANEL_NOTIFY_PROC, debug_proc,
  1275. X            0);
  1276. X
  1277. X        panel_create_item(cmd_window, PANEL_BUTTON,
  1278. X            PANEL_LABEL_IMAGE, live_image->picture,
  1279. X            PANEL_NOTIFY_PROC, live_proc,
  1280. X            0);
  1281. X    }
  1282. X}
  1283. X
  1284. X
  1285. X/*****************************************************************
  1286. X *    init_hs_popup()    -    Create the high score popup
  1287. X *                window.  Get the high scores and
  1288. X *                add them to the window.  Create
  1289. X *                two DONE gadgets for removing the
  1290. X *                chart.
  1291. X *****************************************************************/
  1292. X
  1293. Xinit_hs_popup()
  1294. X{
  1295. X    /* Create the popup sub-frame and sub-window */
  1296. X    hs_popup_frame = window_create(frame, FRAME,
  1297. X                FRAME_LABEL, "        TOP TEN ROBOT HUNTERS",
  1298. X                FRAME_SHOW_LABEL, TRUE,
  1299. X                WIN_SHOW, FALSE,
  1300. X                0);
  1301. X    hs_popup_panel = window_create(hs_popup_frame,
  1302. X                PANEL,
  1303. X                0);
  1304. X
  1305. X    /* Get and update the high score list */
  1306. X    get_hs();
  1307. X    update_hs();
  1308. X
  1309. X    /* Create two DONE buttons */
  1310. X    panel_create_item(hs_popup_panel, PANEL_BUTTON,
  1311. X            PANEL_ITEM_X, ATTR_COL(0),
  1312. X            PANEL_ITEM_Y, ATTR_ROW(HS_NUM_SCORES + 1),
  1313. X            PANEL_LABEL_IMAGE, panel_button_image(hs_popup_panel,
  1314. X                        "DONE", 5,
  1315. X                        0),
  1316. X            PANEL_NOTIFY_PROC, do_pop_proc,
  1317. X            0);
  1318. X    panel_create_item(hs_popup_panel, PANEL_BUTTON,
  1319. X            PANEL_ITEM_X, ATTR_COL(30),
  1320. X            PANEL_ITEM_Y, ATTR_ROW(HS_NUM_SCORES + 1),
  1321. X            PANEL_LABEL_IMAGE, panel_button_image(hs_popup_panel,
  1322. X                        "DONE", 5,
  1323. X                        0),
  1324. X            PANEL_NOTIFY_PROC, do_pop_proc,
  1325. X            0);
  1326. X
  1327. X    /* Fit the panel and the frame */
  1328. X    window_fit(hs_popup_panel);
  1329. X    window_fit(hs_popup_frame);
  1330. X}
  1331. X
  1332. X
  1333. X/*****************************************************************
  1334. X *    init_msg_popup()    -    Create a sub-frame and
  1335. X *                    sub-window to display a
  1336. X *                    message in.
  1337. X *****************************************************************/
  1338. X
  1339. Xinit_msg_popup()
  1340. X{
  1341. X    /* Create sub-frame and sub-window */
  1342. X    msg_popup_frame = window_create(frame, FRAME,
  1343. X                WIN_SHOW, FALSE,
  1344. X                0);
  1345. X    msg_popup_panel = window_create(msg_popup_frame, PANEL,
  1346. X                0);
  1347. X
  1348. X    /* Create message label */
  1349. X    msg_popup_label = panel_create_item(msg_popup_panel, PANEL_MESSAGE,
  1350. X            PANEL_LABEL_STRING, " ",
  1351. X            0);
  1352. X
  1353. X    /* Size to fit message */
  1354. X    window_fit(msg_popup_panel);
  1355. X    window_fit(msg_popup_frame);
  1356. X}
  1357. X
  1358. X
  1359. X/*****************************************************************
  1360. X *    display_msg()    -    Add a message to the popup window
  1361. X *                and display it.
  1362. X *****************************************************************/
  1363. X
  1364. Xdisplay_msg(string, time)
  1365. Xchar *string;
  1366. Xint time;
  1367. X{
  1368. X    int play_x, play_y;        /* Start point of playfield */
  1369. X    int play_width, play_height;    /* Width and height of playfield */
  1370. X    int msg_width, msg_height;    /* Width and height of popup msg */
  1371. X
  1372. X    struct itimerval timer;        /* Timer for removing message */
  1373. X
  1374. X    /* Change the message string */
  1375. X    panel_set(msg_popup_label, PANEL_LABEL_STRING, string, 0);
  1376. X
  1377. X    /* Fit the windows again */
  1378. X    window_fit(msg_popup_panel);
  1379. X    window_fit(msg_popup_frame);
  1380. X
  1381. X    /* Center frame in center of playfield */
  1382. X    play_x = (int) window_get(playfield, WIN_X);
  1383. X    play_y = (int) window_get(playfield, WIN_Y);
  1384. X    play_width = (int) window_get(playfield, WIN_WIDTH);
  1385. X    play_height = (int) window_get(playfield, WIN_HEIGHT);
  1386. X
  1387. X    msg_width = (int) window_get(msg_popup_panel, WIN_WIDTH);
  1388. X    msg_height = (int) window_get(msg_popup_panel, WIN_HEIGHT);
  1389. X
  1390. X    window_set(msg_popup_frame,
  1391. X        WIN_X, play_x + ((play_width - msg_width) >> 1),
  1392. X        WIN_Y, play_y + ((play_height - msg_height) >> 1),
  1393. X        0);
  1394. X
  1395. X    /* Set up time interval */
  1396. X    timer.it_interval.tv_usec = 0;
  1397. X    timer.it_interval.tv_sec = time;
  1398. X    timer.it_value.tv_usec = 0;
  1399. X    timer.it_value.tv_sec = time;
  1400. X
  1401. X    /* Show the panel, wait some time, and remove the panel */
  1402. X    window_set(msg_popup_frame, WIN_SHOW, TRUE, 0);
  1403. X    notify_set_itimer_func(msg_popup_frame, kill_display,
  1404. X            ITIMER_REAL, &timer, NULL);
  1405. X}
  1406. X
  1407. X
  1408. X/*****************************************************************
  1409. X *    kill_display()    -    Remove the message from the screen.
  1410. X *****************************************************************/
  1411. X
  1412. Xkill_display()
  1413. X{
  1414. X    window_set(msg_popup_frame, WIN_SHOW, FALSE, 0);
  1415. X    notify_set_itimer_func(msg_popup_frame, kill_display,
  1416. X            ITIMER_REAL, NULL, NULL);
  1417. X}
  1418. X
  1419. X
  1420. X/*****************************************************************
  1421. X *    update_hs()    -    Update the high score display.
  1422. X *                If called for the first time, then
  1423. X *                create the message panels as well.
  1424. X *****************************************************************/
  1425. X
  1426. Xupdate_hs()
  1427. X{
  1428. X    int i;            /* Loop variable */
  1429. X    char tempstr[80];    /* Temporary storage string */
  1430. X
  1431. X    /* If first time, then build the panels.  Setup the list */
  1432. X    for(i = 0; i < HS_NUM_SCORES; i++) {
  1433. X        if(!hs[i]) {
  1434. X            hs[i] = panel_create_item(hs_popup_panel,PANEL_MESSAGE,
  1435. X                    PANEL_ITEM_X,    ATTR_COL(0),
  1436. X                    PANEL_ITEM_Y,    ATTR_ROW(i),
  1437. X                    0);
  1438. X        }
  1439. X
  1440. X        sprintf(tempstr, "%2d)  %-10s     level %2d     %6d pts",
  1441. X            i + 1, hs_list.names[i], hs_list.levels[i],
  1442. X            hs_list.scores[i]);
  1443. X        panel_set(hs[i], PANEL_LABEL_STRING, tempstr, 0);
  1444. X    }
  1445. X}
  1446. X
  1447. X
  1448. X/*****************************************************************
  1449. X *    get_hs()    -    Get the high scores from the high
  1450. X *                score file.  If open fails, then
  1451. X *                an error is reported and FALSE is
  1452. X *                returned.  TRUE is returned
  1453. X *                otherwise.
  1454. X *****************************************************************/
  1455. X
  1456. Xget_hs()
  1457. X{
  1458. X    int i;            /* Loop variable */
  1459. X    FILE *hs_file;        /* Pointer to the high score file */
  1460. X
  1461. X    /* Open high score file and report any errors */
  1462. X    if(!(hs_file = fopen(HSFILE, "r"))) {
  1463. X        fprintf(stderr, "get_ps: Can't open high score file %s\n",
  1464. X                HSFILE);
  1465. X        return(FALSE);
  1466. X    }
  1467. X
  1468. X    /* Read the high score list and close the file */
  1469. X    fread((char *) &hs_list, sizeof(hs_list), 1, hs_file);
  1470. X    fclose(hs_file);
  1471. X
  1472. X    return(TRUE);
  1473. X}
  1474. X
  1475. X
  1476. X/*****************************************************************
  1477. X *    put_hs        -    Write the new high score list to
  1478. X *                the high score file.  Report any
  1479. X *                errors in opening the file.
  1480. X *****************************************************************/
  1481. X
  1482. Xput_hs()
  1483. X{
  1484. X    FILE *hs_file;        /* Pointer to the high score file */
  1485. X
  1486. X    /* Open the high score file and report any errors */
  1487. X    if(!(hs_file = fopen(HSFILE, "w"))) {
  1488. X        fprintf(stderr, "put_hs: Can't open high score file %s\n",
  1489. X                HSFILE);
  1490. X        return;
  1491. X    }
  1492. X
  1493. X    /* Write the high score list and close the file */
  1494. X    fwrite((char *) &hs_list, sizeof(hs_list), 1, hs_file);
  1495. X    fclose(hs_file);
  1496. X}
  1497. X
  1498. X
  1499. X/*****************************************************************
  1500. X *    make_hs()    -    Add a new high score to the high
  1501. X *                score chart.  First lock the chart
  1502. X *                against access.  Get the current
  1503. X *                score list and add the new score to
  1504. X *                the list.  Write the new list out
  1505. X *                and unlock the file.
  1506. X *****************************************************************/
  1507. X
  1508. Xmake_hs()
  1509. X{
  1510. X    int obtained;        /* Flag indicating successful hs lookup */
  1511. X    int i, j;        /* Loop variables */
  1512. X
  1513. X    /* Lock the high score file and exit if fails */
  1514. X    if(!lock_hs_file())
  1515. X        return;
  1516. X
  1517. X    /* Get the high score file and add the new score */
  1518. X    obtained = get_hs();
  1519. X    for(i = 0; i < 10; i++)
  1520. X        if(hs_list.scores[i] < current_score) {
  1521. X            for(j = 9; j > i; j--) {
  1522. X                hs_list.scores[j] = hs_list.scores[j - 1];
  1523. X                hs_list.levels[j] = hs_list.levels[j - 1];
  1524. X                strcpy(hs_list.names[j], hs_list.names[j - 1]);
  1525. X            }
  1526. X            hs_list.scores[i] = current_score;
  1527. X            hs_list.levels[i] = current_level;
  1528. X            strcpy(hs_list.names[i], getpwuid(getuid())->pw_name);
  1529. X            break;
  1530. X        }
  1531. X
  1532. X    /* If the high score was obtained properly, then write the new list */
  1533. X    if(obtained) {
  1534. X        put_hs();
  1535. X        update_hs();
  1536. X    }
  1537. X
  1538. X    /* Unlock the high score file */
  1539. X    unlock_hs_file();
  1540. X}
  1541. X
  1542. X
  1543. X/*****************************************************************
  1544. X *    lock_hs_file()    -    Lock the high score file against
  1545. X *                access by another program.  Creates
  1546. X *                a link to the high score file.
  1547. X *                If the link fails, it will try
  1548. X *                multiple times (waiting for other
  1549. X *                process to give it up) and then it
  1550. X *                will give up and register an error.
  1551. X *****************************************************************/
  1552. X
  1553. Xlock_hs_file()
  1554. X{
  1555. X    int count = 0;        /* Counter for number of attempts made */
  1556. X
  1557. X    /* Try to create the link */
  1558. X    while(link(HSFILE, HSLOCK) == -1 &&
  1559. X        count < MAX_LOCK_TRIES)
  1560. X            count++;
  1561. X
  1562. X    /* If failed, then send an error message */
  1563. X    if(count >= MAX_LOCK_TRIES)
  1564. X        fprintf(stderr, "Could not create lock %s\n",
  1565. X            HSLOCK);
  1566. X
  1567. X    return(count < MAX_LOCK_TRIES);
  1568. X}
  1569. X
  1570. X
  1571. X/*****************************************************************
  1572. X *    unlock_hs_file()    -    Unlock the high score file
  1573. X *                    so that other processes can
  1574. X *                    access it.
  1575. X *****************************************************************/
  1576. X
  1577. Xunlock_hs_file()
  1578. X{
  1579. X    /* Unlink lock file */
  1580. X    unlink(HSLOCK);
  1581. X}
  1582. X
  1583. X
  1584. X/*****************************************************************
  1585. X *    dump_pic()    -    Dump the screen to a file.
  1586. X *****************************************************************/
  1587. X
  1588. Xdump_pic()
  1589. X{
  1590. X    char *filename, command[512];
  1591. X    int x, y, X, Y;
  1592. X
  1593. X    if((filename = tempnam(".", "rdump")) == NULL)
  1594. X        fprintf(stderr, "Can't make dumpfile!\n");
  1595. X    else {
  1596. X        x = (int) window_get(frame, WIN_X);
  1597. X        y = (int) window_get(frame, WIN_Y);
  1598. X        X = (int) window_get(frame, WIN_WIDTH);
  1599. X        Y = (int) window_get(frame, WIN_HEIGHT);
  1600. X        sprintf(command, "screendump -x%d -y%d -X%d -Y%d %s",
  1601. X            x, y, X, Y, filename);
  1602. X        system(command);
  1603. X    }
  1604. X}
  1605. X
  1606. X
  1607. X/*****************************************************************
  1608. X *    dump_hs()    -    Dump the high score to a file.
  1609. X *****************************************************************/
  1610. X
  1611. Xdump_hs()
  1612. X{
  1613. X    char *filename, command[512];
  1614. X    int x, y, X, Y;
  1615. X
  1616. X    if((filename = tempnam(".", "hdump")) == NULL)
  1617. X        fprintf(stderr, "Can't make dumpfile!\n");
  1618. X    else {
  1619. X        x = (int) window_get(hs_popup_frame, WIN_X) +
  1620. X            (int) window_get(frame, WIN_X);
  1621. X        y = (int) window_get(hs_popup_frame, WIN_Y) +
  1622. X            (int) window_get(frame, WIN_Y);
  1623. X        X = (int) window_get(hs_popup_frame, WIN_WIDTH);
  1624. X        Y = (int) window_get(hs_popup_frame, WIN_HEIGHT);
  1625. X        sprintf(command, "screendump -x%d -y%d -X%d -Y%d %s",
  1626. X            x, y, X, Y, filename);
  1627. X        system(command);
  1628. X    }
  1629. X}
  1630. END_OF_FILE
  1631. if test 16439 -ne `wc -c <'sunbots.c'`; then
  1632.     echo shar: \"'sunbots.c'\" unpacked with wrong size!
  1633. fi
  1634. # end of 'sunbots.c'
  1635. fi
  1636. if test -f 'sunbots.h' -a "${1}" != "-c" ; then 
  1637.   echo shar: Will not clobber existing file \"'sunbots.h'\"
  1638. else
  1639. echo shar: Extracting \"'sunbots.h'\" \(5034 characters\)
  1640. sed "s/^X//" >'sunbots.h' <<'END_OF_FILE'
  1641. X/*****************************************************************
  1642. X *
  1643. X *    sunbots.h    -    Sunview Robots Header File
  1644. X *
  1645. X *    Created -- 1/5/90    Kevin Wright
  1646. X *
  1647. X *****************************************************************/
  1648. X
  1649. X#ifndef SUNBOTS_H
  1650. X# define SUNBOTS_H
  1651. X
  1652. X# include <suntool/sunview.h>
  1653. X# include <suntool/canvas.h>
  1654. X# include <suntool/panel.h>
  1655. X# include <suntool/icon.h>
  1656. X# include <suntool/tty.h>
  1657. X# include <stdio.h>
  1658. X# ifndef SUNOS3_5
  1659. X#  include <suntool/alert.h>
  1660. X# endif
  1661. X# include <suntool/seln.h>
  1662. X# include <pwd.h>
  1663. X# include <sys/time.h>
  1664. X# include <sunwindow/notify.h>
  1665. X# include "images.h"
  1666. X
  1667. X/*
  1668. X *    Defines
  1669. X */
  1670. X
  1671. X# define SEED(x)            (srandom(x))    /* Random numbers */
  1672. X# define RND(x)                ((random() >> 3) % x)
  1673. X
  1674. X# define NORTH                0    /* North */
  1675. X# define NORTH_WEST            1    /* North-west */
  1676. X# define NORTH_EAST            2    /* North-east */
  1677. X# define SOUTH                3    /* South */
  1678. X# define SOUTH_WEST            4    /* South-west */
  1679. X# define SOUTH_EAST            5    /* South-east */
  1680. X# define EAST                6    /* East */
  1681. X# define WEST                7    /* West */
  1682. X# define NO_MOVE            8    /* No Direction */
  1683. X
  1684. X# define COLLISION_HUMAN        1    /* Collision with human */
  1685. X# define COLLISION_ROBOT        2    /* Collision with robot */
  1686. X# define COLLISION_TRASH        3    /* Collision with trash */
  1687. X# define COLLISION_GEM            4    /* Collision with gem */
  1688. X# define COLLISION_OTHER        5    /* Unknown collision */
  1689. X
  1690. X# define LIVE_STATE            1    /* Robot is alive */
  1691. X# define DEAD_STATE            2    /* Robot is dead */
  1692. X# define ALL_STATES            3    /* Alive or dead */
  1693. X
  1694. X# define SPEEDER_LEVEL            5    /* Starting speeder level */
  1695. X# define SPEEDER_CHANCE            10    /* Chance of being fast */
  1696. X
  1697. X# define ALL_ROBOTS            1    /* All robots */
  1698. X# define NORMAL_ROBOT            2    /* Normal robot */
  1699. X# define SPEEDER_ROBOT            3    /* Faster robot */
  1700. X# define HUMAN                4    /* Not a robot */
  1701. X# define GEM                5    /* A gem */
  1702. X
  1703. X# define ROW_HEIGHT            16    /* Height of a row */
  1704. X# define COL_WIDTH            16    /* Width of a column */
  1705. X# define SCRN_ROWS            40    /* Rows per screen */
  1706. X# define SCRN_COLS            40    /* Columns per screen */
  1707. X# define SCREEN_HEIGHT            (SCRN_ROWS * ROW_HEIGHT)
  1708. X# define SCREEN_WIDTH            (SCRN_COLS * COL_WIDTH)
  1709. X
  1710. X# define TARDIS_BLINK_RATE        10000    /* Loop for tardis blink */
  1711. X# define SONIC_CYCLE_RATE        5000    /* Loop for sonic cycle */
  1712. X
  1713. X# define HS_NAME_LEN            20    /* Length of high score name */
  1714. X# define HS_NUM_SCORES            10    /* Number of high scores */
  1715. X# ifndef HSFILE                    /* Sunbot high score file */
  1716. X#  define HSFILE            "/usr/games/lib/.sunbots.hs"
  1717. X# endif
  1718. X# ifndef HSLOCK                    /* Sunbot hs lock file */
  1719. X#  define HSLOCK            "/usr/games/lib/.sunbots.hs.lock"
  1720. X# endif
  1721. X# define MAX_LOCK_TRIES            50
  1722. X
  1723. X# define DEBUG_UID            114    /* Uid of debugger */
  1724. X
  1725. X/*
  1726. X *    Structures
  1727. X */
  1728. X
  1729. Xtypedef struct screen_item {
  1730. X    int            row, col;    /* Row and column of item */
  1731. X    int            oldrow, oldcol;    /* Old position of item */
  1732. X    int            type;        /* Type of robot */
  1733. X    int            dead;        /* Flag indicating death */
  1734. X    Image            image;        /* Pointer to panel item */
  1735. X    struct screen_item    *next;        /* Pointer to next structure */
  1736. X} *ScreenItem;
  1737. X
  1738. Xtypedef struct {
  1739. X    char    names[HS_NUM_SCORES][HS_NAME_LEN + 1];    /* Names of scorers */
  1740. X    int    scores[HS_NUM_SCORES];            /* High scores */
  1741. X    int    levels[HS_NUM_SCORES];            /* High levels */
  1742. X} HiScoreList;
  1743. X
  1744. X/*
  1745. X *    Global Variables
  1746. X */
  1747. X
  1748. Xextern Frame        frame;        /* Base frame for window */
  1749. Xextern Frame        hs_popup_frame;    /* High score popup sub-frame */
  1750. Xextern Frame        msg_popup_frame;/* Message popup sub-frame */
  1751. Xextern Canvas        playfield;    /* Main battlefield for robots */
  1752. Xextern Pixwin        *playfield_pw;    /* Pixwin for the battlefield */
  1753. Xextern Panel        msg_window;    /* Panel for displaying score */
  1754. Xextern Panel        cmd_window;    /* Panel that contains buttons */
  1755. Xextern Panel        mov_window;    /* Panel containing movement gadgets */
  1756. Xextern Panel        hs_popup_panel;    /* High score popup sub-window */
  1757. Xextern Panel        msg_popup_panel;/* Message popup sub-window */
  1758. Xextern Panel_item    score;        /* Item to display score and level */
  1759. Xextern Panel_item    msg_popup_label;/* Label for popup panel */
  1760. Xextern Panel_item    hs[10];        /* Top ten scores */
  1761. Xextern ScreenItem    human;        /* Structure containing human */
  1762. Xextern ScreenItem    robot_list;    /* Linked list of robots */
  1763. X
  1764. Xextern HiScoreList    hs_list;        /* High score chart */
  1765. X
  1766. Xextern int        current_level;        /* Current level number */
  1767. Xextern int        current_score;        /* Current score */
  1768. Xextern int        screwdriver_uses;    /* How many sonic blasts */
  1769. Xextern int        last_stand_set;        /* Are we doing a last stand */
  1770. Xextern int        lives_remaining;    /* Number of lives remaining */
  1771. X
  1772. X
  1773. X/*
  1774. X *    Functions
  1775. X */
  1776. X
  1777. Xint init_msg_window(), init_playfield(), init_cmd_window(), init_hs_popup();
  1778. Xint new_proc(), filer_proc(), move_proc(), move_human(), get_hs(), put_hs();
  1779. Xint teleport_proc(), sonic_proc(), stand_proc(), quit_proc(), make_level();
  1780. Xint destroy_robots(), create_robots(), find_empty(), place_item();
  1781. Xint move_robots(), collision(), all_dead(), update_score(), update_level();
  1782. Xint do_death(), update_hs(), do_pop_proc(), lock_hs_file(), init_msg_popup();
  1783. Xint unlock_hs_file(), make_hs(), debug_proc(), live_proc(), display_msg();
  1784. Xint kill_display(), setup_proc(), startup_proc(), set_image();
  1785. X
  1786. XScreenItem occupied();
  1787. X
  1788. X#endif    /* SUNBOTS_H */
  1789. END_OF_FILE
  1790. if test 5034 -ne `wc -c <'sunbots.h'`; then
  1791.     echo shar: \"'sunbots.h'\" unpacked with wrong size!
  1792. fi
  1793. # end of 'sunbots.h'
  1794. fi
  1795. echo shar: End of archive 1 \(of 3\).
  1796. cp /dev/null ark1isdone
  1797. MISSING=""
  1798. for I in 1 2 3 ; do
  1799.     if test ! -f ark${I}isdone ; then
  1800.     MISSING="${MISSING} ${I}"
  1801.     fi
  1802. done
  1803. if test "${MISSING}" = "" ; then
  1804.     echo You have unpacked all 3 archives.
  1805.     rm -f ark[1-9]isdone
  1806. else
  1807.     echo You still need to unpack the following archives:
  1808.     echo "        " ${MISSING}
  1809. fi
  1810. ##  End of shell archive.
  1811. exit 0
  1812.